package com.cw.subject.infra.basic.service.impl;

import com.cw.subject.infra.basic.entity.SubjectInfoPO;
import com.cw.subject.infra.basic.mapper.SubjectInfoPODao;
import com.cw.subject.infra.basic.service.SubjectInfoPOService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 题目信息表(SubjectInfoPO)表服务实现类
 *
 * @author makejava
 * @since 2024-04-11 15:27:20
 */
@Service("subjectInfoService")
public class SubjectInfoPOServiceImpl implements SubjectInfoPOService {
    @Resource
    private SubjectInfoPODao subjectInfoPODao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SubjectInfoPO queryById(Integer id) {
        return this.subjectInfoPODao.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param subjectInfoPO 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(SubjectInfoPO subjectInfoPO) {
        return this.subjectInfoPODao.insert(subjectInfoPO);
    }

    /**
     * 修改数据
     *
     * @param subjectInfoPO 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectInfoPO update(SubjectInfoPO subjectInfoPO) {
        this.subjectInfoPODao.update(subjectInfoPO);
        return this.queryById(subjectInfoPO.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.subjectInfoPODao.deleteById(id) > 0;
    }

    @Override
    public int countByCondition(SubjectInfoPO subjectInfoPO, Integer categoryId, Integer labelId) {
        return this.subjectInfoPODao.countByCondition(subjectInfoPO, categoryId, labelId);
    }

    @Override
    public List<SubjectInfoPO> queryPage(SubjectInfoPO subjectInfoPO, Integer categoryId, Integer labelId, int start, Integer pageSize) {
        return this.subjectInfoPODao.queryPage(subjectInfoPO, categoryId, labelId, start, pageSize);
    }
}
